using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using ViCode_LeVi.Controls.Logs;

namespace ViCode_LeVi.Controls.Reports
{
    public partial class ActionSubReport : DevExpress.XtraReports.UI.XtraReport
    {
        
        public ActionSubReport()
        {
            this.InitializeComponent();
        }

        private bool CreateDataBindings()
        {
            bool flag = true;
            try
            {
                this.cellName.DataBindings.Add("Text", base.DataSource, "Name");
                this.cellDuration.DataBindings.Add("Text", base.DataSource, "Duration");
                this.cellState.DataBindings.Add("Text", base.DataSource, "State");
                this.cellStartDate.DataBindings.Add("Text", base.DataSource, "StartDate");
                this.cellResult.DataBindings.Add("Text", base.DataSource, "Result");
                this.cellProcedure.DataBindings.Add("Text", base.DataSource, "Procedure");
                this.cellBenefit.DataBindings.Add("Text", base.DataSource, "Benefit");
                this.cellEffort.DataBindings.Add("Text", base.DataSource, "Effort");
            }
            catch (Exception exception)
            {
                flag = false;
                //rsErr = "Fehler in ActionSubReport.CreateDataBindings: " + exception.Message;
                Log.LogException(exception);
            }
            return flag;
        }

        public bool CreateReport(ref bool bActions)
        {
            bool flag = true;
            try
            {
                //todo
                var data = new ReportDataSourceHelper().GetReportActionList();;
                base.DataSource = data;
                if (data .Length> 0)
                {
                    bActions = true;
                    return this.CreateDataBindings();
                }
                bActions = false;
            }
            catch (Exception exception)
            {
                flag = false;
                //rsErr = "Fehler in ActionSubReport.CreateReport: " + exception.Message;
                Log.LogException(exception);
            }
            return flag;
        }
        
     
    }
}
